﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using FrienDev.BusinessRules;
using System.Collections.Generic;
using FrienDev.Data;

public partial class Controls_Activity_MemberList : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Request["activityid"] != null)
        {
            int activityID = 0;
            int.TryParse(Request["activityId"], out activityID);
            List<User> myData;
            allMemberLink.NavigateUrl = "/Activity/ActivityMemberList.aspx?activityId=" + activityID;
            if (!IsMemberJoined)
            {
                title.Text = "待批准人员";
                IEnumerable<User> tempData = ActivityRules.Instance.GetActivityCandidate(activityID, 15);
                if (tempData == null)
                    return;
                myData = tempData.ToList<User>();
            }
            else
            {
                title.Text = "活动参加者";
                IEnumerable<User> tempData = ActivityRules.Instance.GetActivityJoined(activityID, 15);
                if (tempData == null)
                    return;
                myData = tempData.ToList<User>();
            }
            DataList1.DataSource = myData;
            DataList1.DataBind();
        }
    }
    protected void DataList1_Load(object sender, EventArgs e)
    {

    }
    protected void HY_DataBinding(object sender, EventArgs e)
    {
        HyperLink hy = sender as HyperLink;
        hy.NavigateUrl = ApiHelper.Instance.GetUserHomepageLink(hy.NavigateUrl);
    }

    protected void Img_DataBinding(object seder, EventArgs e)
    {
        Image img = seder as Image;
        img.ImageUrl = ApiHelper.Instance.GetUserLogoUrl(img.ImageUrl);
    }

    public bool IsMemberJoined { get; set; }
}
